package com.Web;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import util.DateUtil;

import com.Dao.TaskDao;

import com.entity.Task;

public class SavaEditTK extends HttpServlet {

	private static final long serialVersionUID = 1L;

	@Override
	protected void service(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		HttpSession session = request.getSession();

		String id = request.getParameter("id");
		String Tname = request.getParameter("name");
		String Tarea = request.getParameter("desc");
		String state = request.getParameter("select");
		String Begin = request.getParameter("begin");
		String End = request.getParameter("end");
		String level = request.getParameter("select1");
		String ralee = request.getParameter("jin");
		
		TaskDao dao = new TaskDao();
		Task tk = new Task();
		
		
		tk.setId(Integer.parseInt(id));
		tk.setName(Tname);
		tk.setState(state);
		tk.setDesc(Tarea);
		tk.setCreatetime(DateUtil.getNow());
		tk.setBegintime(Begin);
		tk.setEndtime(End);
		tk.setLevel(level );
		tk.setRale(Integer.parseInt(ralee));
		
		dao.update(tk);
		session.setAttribute("tk", tk);
		request.getRequestDispatcher("/WEB-INF/views/task.jsp").forward(
				request, response);
	}

}
